home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / pasform.arc / PASFORM.DOC next >
Encoding:
Text File  |  1986-05-11  |  77.0 KB  |  2,039 lines

  1.  
  2.  
  3.  
  4.  PTOOLS - PASCAL SOFTWARE WRITING TOOLS.                      03 Jan 79
  5.  
  6.   PASCAL                   TTTTTTTT  OOOOO/   OOOOO/  LL        SSSSS
  7.   PP   PP                     TT    OO   OO  OO   OO  LL       SS   SS  
  8.   AA   AA                     TT    OO  /OO  OO  /OO  LL       SS
  9.   SSSSSS      SOFTWARE        TT    OO / OO  OO / OO  LL        SSSSS
  10.   CC                          TT    OO/  OO  OO/  OO  LL            SS  
  11.   AA                          TT    OO   OO  OO   OO  LL       SS   SS  
  12.   LL                          TT    /OOOOO   /OOOOO   LLLLLLL   SSSSS
  13.  
  14.                  THIS IS THE PTOOLS WRITEUP     79/01/01.
  15.                                 - ANDY MICKEL
  16.                                 - JOHN P.  STRAIT
  17.                                 - RICK L.  MARCUS
  18.                                 - UNIVERSITY COMPUTER CENTER  
  19.                                 - UNIVERSITY OF MINNESOTA
  20.  
  21.       THE PTOOLS WRITEUP DESCRIBES VARIOUS SOFTWARE-WRITING TOOLS WHICH
  22.  AID  THE  PASCAL  PROGRAMMER  IN  ALL  PHASES  OF  PROGRAM  CODING AND
  23.  DEVELOPMENT--FROM ENTRY OF SOURCE CODE  THROUGH  DOCUMENTATION.   THIS
  24.  SHEET IS MERELY THE TABLE OF CONTENTS FOR ALL OF THE TOOLS AVAILABLE.
  25.  
  26.  NAME     PAGES  DESCRIPTION
  27.  ----     -----  -----------
  28.  
  29.  COMPARE  5      COMPARE TWO TEXTFILES AND REPORT THEIR DIFFERENCES.
  30.  
  31.  MEASURE  5      OBTAIN PERFORMANCE MEASUREMENTS OF A PASCAL PROGRAM
  32.                     USING AUGMENT AND ANALYZE.
  33.  
  34.  PASCODE  1      DECOMPILE A RELOCATABLE-BINARY FILE PRODUCED BY THE
  35.                     PASCAL COMPILER.
  36.  
  37.  PASCREF  2      CROSS REFERENCE IDENTIFIERS IN A PASCAL PROGRAM AND
  38.                     GIVE A PROCEDURE MAP.
  39.  
  40.  PASVERT  2      CONVERT A TEXTFILE FROM/TO CDC SCIENTIFIC CHARACTER
  41.                     SET TO/FROM CDC ASCII SUBSET CHARACTER SET.
  42.  
  43.  PRETTY   3      PRETTYPRINT (AUTOMATICALLY INDENT) A PASCAL PROGRAM.
  44.  
  45.  SPRUCE   10     PRETTYPRINT (AUTOMATICALLY INDENT AND FORMAT) A
  46.                     PASCAL PROGRAM ACCORDING TO VARIOUS OPTIONS.
  47.  
  48.  WRITE    6      TRANSLATE CHARACTER SETS IN WRITEUPS.
  49.  
  50.       AT  THE  UNIVERSITY OF MINNESOTA THIS DOCUMENT IS AVAILABLE AS AN
  51.  INDEXED WRITEUP WITH CHAPTERS OF A FEW PAGES EACH.   THIS  ALLOWS  THE
  52.  RETRIEVAL  OF  SELECTED  CHAPTERS  OR  THE  ENTIRE  WRITEUP.  TO GET A
  53.  WRITEUP OF A SPECIFIC TOOL AT THE UNIVERSITY OF MINNESOTA, USE ONE  OF
  54.  THE  COMMANDS  BELOW.  AT OTHER SITES, THE METHOD TO RETRIEVE SEPARATE
  55.  CHAPTERS MAY BE DIFFERENT OR IMPOSSIBLE.
  56.  
  57.       WRITEUP(PTOOLS=NAME)  -  PRINT THE WRITEUP FOR "NAME".  
  58.       WRITEUP(PTOOLS=NAME1+...+NAMEN)  -  PRINT THE NAMED TOOLS.
  59.       WRITEUP(PTOOLS=*)  -  PRINT THE ENTIRE PTOOLS WRITEUP.  
  60.  
  61.  
  62.                                  - 1 -
  63.  
  64.  
  65.  COMPARE - Compare Two Textfiles                              03 Jan 79
  66.  
  67.       Compare - Compare Two Textfiles and Report Their Differences
  68.  
  69.                             James F.  Miner
  70.                Social Science Research Facilities Center
  71.                               Andy Mickel
  72.                        University Computer Center
  73.                         University of Minnesota
  74.                        Minneapolis, MN 55455 USA
  75.  
  76.                        Copyright (c) 1977, 1978.
  77.  
  78.  What COMPARE Does
  79.  -----------------
  80.  
  81.       COMPARE is used to display the differences  between  two  similar
  82.  texts  (referred  to as "FILEA" and "FILEB").  Such textfiles could be  
  83.  Pascal source programs, character data, documentation, etc.
  84.  
  85.       COMPARE is line-oriented, meaning the smallest unit of comparison
  86.  is  the  text  line  (ignoring  trailing blanks).  COMPARE generates a
  87.  report of differences (mismatches  or  extra  text)  between  the  two
  88.  textfiles.   The criterion for determining the locality of differences
  89.  is the number of consecutive lines on each file which must match after
  90.  a prior mismatch, and can be selected as a parameter.
  91.  
  92.       By selecting other parameters, you can direct COMPARE to restrict
  93.  the comparison to various linewidths, mark column-wise the differences
  94.  in  pairs  of  mismatched lines, generate text-editor directives to be
  95.  used to convert FILEA into FILEB, or generate  a  listing  which  will
  96.  flag  lines on FILEB indicating their addition or deletion as a result
  97.  of the application of the editor directives.
  98.  
  99.  How to Use COMPARE
  100.  ------------------
  101.  
  102.       COMPARE is available as an operating system control statement  on
  103.  CDC  6000/Cyber  70,170  computer  systems.   The  general form of the
  104.  control statement is:  
  105.  
  106.       COMPARE(a,b,list,modfile/options)
  107.  
  108.       COMPARE.  means  COMPARE(FILEA,FILEB,MODS/C6,D,W120) 
  109.   
  110.       "FILEA" and "FILEB" are the names  of  the  two  textfiles  being 
  111.  compared, "OUTPUT" is the report file, and "MODS" is the file name for 
  112.  the  generation  of  text-editor  directives  if  the  "M"  option  is 
  113.  selected--see below.  The various options are:  C, D, F, M, P, and W.
  114.   
  115.   
  116.   
  117.                                  - 1 -
  118.   
  119.  
  120.  COMPARE - Compare Two Textfiles                              03 Jan 79 
  121.   
  122.   Cn   Match Criterion (1 <= n <= 100). 
  123.           C  determines  the  number  of consecutive lines on each file
  124.           which  must  match  in  order  that  they  be  considered  as
  125.           terminating  a prior mismatch.  C therefore affects COMPARE's 
  126.           "sensitivity" to the "locality" of differences.  Setting C to
  127.           a  large value tends to produce fewer (but longer) mismatches
  128.           than does a small value.  C6 appears to give good results  on
  129.           Pascal  source  files,  but  may  be  inappropriate for other
  130.           applications. 
  131.           Default:  C6. 
  132.  
  133.   D    Report Differences. 
  134.           D directs  COMPARE  to  display  mismatches  and  extra  text 
  135.           between  FILEA and FILEB in a clearly annotated report.  Only 
  136.           one of D, F, or M can be explicitly selected at one time.
  137.           Default:  selected. 
  138.  
  139.   F    Select Flag-form output. 
  140.           F directs COMPARE to list FILEB annotated with lines prefixed
  141.           by  an  "A"  or  "D"  indicating  "additions"  or "deletions" 
  142.           respectively.  Such modifications could have  been  generated 
  143.           with  the M option.  Only one of D, F, or M can be explicitly 
  144.           selected at one time.
  145.           Default:  not selected.
  146.  
  147.   M    Produce MODS file. 
  148.           M directs COMPARE to produce a file of "INSERT"  or  "DELETE"
  149.           directives  ready  for  the CDC MODIFY or UPDATE text editors 
  150.           (an "IDENT" directive must be  added).   The  insertions  and
  151.           deletions  will  convert  FILEA  into FILEB.  FILEA and FILEB
  152.           should be files with sequencing appearing in  columns  beyond
  153.           the  linewidth  specified  by  the W option.  This is true of
  154.           MODIFY and  UPDATE  "COMPILE"  files  (W72  is  recommended).
  155.           Sequence numbers are of the form: 
  156.  
  157.                {Blanks} IdentName {Blanks} UnsignedInteger. 
  158.  
  159.           Only  one  of  D,  F,  or M can be explicitly selected at one 
  160.           time. 
  161.           Default:  not selected.
  162.  
  163.   P    Mark Pairs of mismatched lines.
  164.           P alters the action of the D directive by  marking  differing
  165.           columns in pairs of lines which mismatch in sections of equal
  166.           length.  This is especially useful for comparing packed  data
  167.           files. 
  168.           Default:  not selected.
  169.  
  170.   Wn   Specify significant line Width (length) (10 <= n <= 150). 
  171.           W  determines  the fixed number of columns of each line which 
  172.           will be compared.  W is ideal to use when  sequence  informa-
  173.           tion is present at the right edge of the text file. 
  174.           Default:  W120. 
  175.   
  176.   
  177.  
  178.                                  - 2 -
  179.   
  180.  
  181.  COMPARE - Compare Two Textfiles                              03 Jan 79 
  182.   
  183.  Example
  184.  -------
  185.  
  186.  Suppose FILEA is:
  187.  
  188.          PROGRAM L2U(INPUT, OUTPUT);
  189.           (* CONVERT CDC 6/12-ASCII LOWER-CASE
  190.              LETTERS TO UPPER CASE.  *) 
  191.          BEGIN
  192.           WHILE NOT EOF(INPUT) DO 
  193.            BEGIN
  194.             WHILE NOT EOLN(INPUT) DO
  195.              BEGIN
  196.               IF INPUT^ <> CHR(76) THEN WRITE(INPUT^);
  197.               GET(INPUT)
  198.              END; 
  199.             READLN; 
  200.             WRITELN 
  201.            END; 
  202.           (*ALL DONE.*) 
  203.          END. 
  204.   
  205.   
  206.   
  207.  and FILEB is: 
  208.  
  209.          PROGRAM U2L(INPUT, OUTPUT);
  210.           (* CONVERT CDC ASCII UPPER-CASE LETTERS 
  211.              TO 6/12 LOWER CASE.  *)
  212.          BEGIN
  213.           WHILE NOT EOF(INPUT) DO 
  214.            BEGIN
  215.             WHILE NOT EOLN(INPUT) DO
  216.              BEGIN
  217.               IF INPUT^ IN ['A'..'Z'] THEN WRITE(CHR(76)); 
  218.               WRITE(INPUT^); 
  219.               GET(INPUT)
  220.              END; 
  221.             READLN; 
  222.             WRITELN 
  223.            END; 
  224.          END. 
  225.   
  226.   
  227.   
  228.   
  229.   
  230.   
  231.  
  232.                                  - 3 -
  233.   
  234.  
  235.  COMPARE - Compare Two Textfiles                              03 Jan 79 
  236.   
  237.  then a report from COMPARE looks like this:
  238.  
  239.    COMPARE,L2U,U2L,LIST/C1,D,P.                     78/12/31. 20.23.25. 
  240.    COMPARE VERSION 3.0 CDC                         (78/12/19) 
  241.  
  242.    OUTPUT OPTION    = DIFFERENCES.
  243.    INPUT LINE WIDTH = 120 CHARACTERS. 
  244.    MATCH CRITERION  = 1 LINES.
  245.  
  246.    FILEA: L2U 
  247.    FILEB: U2L 
  248.   
  249.          ***********************************
  250.    MISMATCH: L2U LINES 1 THRU 3 <NOT EQUAL TO> U2L LINES 1 THRU 3:
  251.  
  252.  A    1. PROGRAM L2U(INPUT, OUTPUT);
  253.  B    1. PROGRAM U2L(INPUT, OUTPUT);
  254.                  ^ ^
  255.  
  256.  A    2.  (* CONVERT CDC 6/12-ASCII LOWER-CASE
  257.  B    2.  (* CONVERT CDC ASCII UPPER-CASE LETTERS 
  258.                          ^^^^^^^^^^^^^^^^^^^^^^^^ 
  259.  
  260.  A    3.     LETTERS TO UPPER CASE.  *) 
  261.  B    3.     TO 6/12 LOWER CASE.  *)
  262.              ^^^^^^^ ^ ^^^^^^^^^^^^ ^^
  263.  
  264.          ***********************************
  265.    MISMATCH: L2U LINE 9 <NOT EQUAL TO> U2L LINES 9 THRU 10: 
  266.  
  267.  A    9.      IF INPUT^ <> CHR(76) THEN WRITE(INPUT^);
  268.  
  269.  B    9.      IF INPUT^ IN ['A'..'Z'] THEN WRITE(CHR(76)); 
  270.  B   10.      WRITE(INPUT^); 
  271.  
  272.          ***********************************
  273.    EXTRA TEXT ON L2U, BETWEEN LINES 15 AND 16 OF U2L
  274.  
  275.  A   15.  (*ALL DONE.*) 
  276.   
  277.  How COMPARE Works
  278.  -----------------
  279.  
  280.       COMPARE employs a simple backtracking-search algorithm to isolate 
  281.  mismatches  from  their  surrounding  matches.  Each mismatch requires 
  282.  dynamic storage roughly  proportional  to  the  size  of  the  largest 
  283.  mismatch,  and  time roughly proportional to the square of the size of 
  284.  the mismatch.  Thus it may not be feasible to  use  COMPARE  on  files 
  285.  with very long mismatches. 
  286.   
  287.   
  288.   
  289.  
  290.                                  - 4 -
  291.   
  292.  
  293.  COMPARE - Compare Two Textfiles                              03 Jan 79 
  294.   
  295.  History
  296.  -------
  297.  
  298.       COMPARE was developed as a portable-Pascal software tool by James 
  299.  Miner  of  the  Social  Science  Research  Facilities  Center  at  the 
  300.  University  of  Minnesota,  in early 1977.  It was written in standard
  301.  Pascal and developed initially under CDC 6000  Pascal.   Although  the 
  302.  original  version  simply  reported differences in a textfile, COMPARE
  303.  was designed to fit  naturally  into  a  larger  text-editing  system.
  304.  Plans  for  COMPARE's  accommodating  later  enhancements  to generate 
  305.  text-editor directives were made from the  beginning.   In  summer  of
  306.  1977,  John  Strait  at  the  University  of Minnesota Computer Center 
  307.  adapted COMPARE not only to generate such a  modifications  file,  but
  308.  also flag-form output and user-selectable options. 
  309.  
  310.       COMPARE has been distributed to several Pascal enthusiasts in the 
  311.  United States who have made it operational on other Pascal implementa- 
  312.  tions.   See  Pascal  News #12, May, 1978, pages 20-23.  In late 1978,
  313.  Willett Kempton of the Anthropology Department at  the  University  of
  314.  California  Berkeley,  installed  COMPARE  (with  no  changes required 
  315.  whatsoever) under Berkeley UNIX Pascal on a PDP 11/70 computer system. 
  316.  He  later adapted the program to note column-wise differences in pairs
  317.  of different lines and made minor changes to the format of the report.
  318.  
  319.       Rick  Marcus  and  Andy  Mickel  at  the  University of Minnesota
  320.  Computer Center made minor enhancements to COMPARE and fully  documen- 
  321.  ted it it for Release 3 of Pascal 6000 in December, 1978.
  322.  
  323.       COMPARE  is  a  model  program  in  many  respects.  It serves to 
  324.  illustrate just how powerful and flexible such  a  comparison  program 
  325.  can be. 
  326.   
  327.   
  328.   
  329.   
  330.   
  331.   
  332.   
  333.   
  334.   
  335.   
  336.   
  337.   
  338.   
  339.  
  340.                                  - 5 -
  341.   
  342.  
  343.  MEASURE - Performance Measurement of Pascal Programs         03 Jan 79 
  344.   
  345.                PERFORMANCE MEASUREMENT OF PASCAL PROGRAMS 
  346.                        USING AUGMENT AND ANALYZE
  347.  
  348.                                     - Andy Mickel 78/03/14. 
  349.                                       University Computer Center 
  350.                                       University of Minnesota
  351.                                       Minneapolis, MN 55455 
  352.   
  353.  What AUGMENT and ANALYZE Do 
  354.  ---------------------------
  355.  
  356.       Suppose  you  want  to  examine  the execution efficiency of your 
  357.  Pascal program--perhaps to make improvements to those parts which take 
  358.  the most computer time. 
  359.  
  360.       AUGMENT and ANALYZE are designed to obtain rough measures of such
  361.  execution times, particularly for large Pascal programs.  Unlike other
  362.  kinds  of  performance  measurement,  AUGMENT  and  ANALYZE assume the
  363.  PROCEDURE and FUNCTION to be the smallest unit  of  a  program  to  be 
  364.  monitored.   This  is  a  satisfactory assumption because well-written
  365.  Pascal programs produced by stepwise refinement naturally are composed
  366.  of proper-sized procedures and functions. 
  367.  
  368.       The general principle used by these programs is that the value of
  369.  the non-standard Pascal function  CLOCK  (which  returns  the  elapsed
  370.  processing  time  in  milliseconds)  can  be  sampled  at procedure or
  371.  function entry and  exit.   When  the  the  expression    (exittime  -
  372.  entrytime),  is  evaluated the time spent within the particular proce- 
  373.  dure or function can be ascertained. 
  374.  
  375.       AUGMENT is the program which inserts the necessary CLOCK-sampling 
  376.  code  into your Pascal source program for every procedure and function 
  377.  entry and exit.   It  thus  causes  your  program  to  capture  timing
  378.  information and to write it out to a file.
  379.  
  380.       Next  you  compile  and  execute  your  program,  which  actually
  381.  produces the file of dynamic timing measurements.
  382.  
  383.       ANALYZE then reads the timing file produced, and writes a report, 
  384.  which  gives  the  name  of  each procedure or function, the number of
  385.  times it was called, and the execution time it consumed for all  calls 
  386.  and per call.
  387.  
  388.       AUGMENT  and  ANALYZE therefore provide a nearly machine-indepen- 
  389.  dent method for gathering performance-measurement data about a  Pascal
  390.  program.  Most Pascal implementations have the required CLOCK function
  391.  which returns the elapsed processor time in milliseconds. 
  392.  
  393.       It is sometimes necessary to exclude the monitoring of excessive- 
  394.  ly  called  procedures  and functions in large programs.  A feature of 
  395.  AUGMENT allows you to specify any number of names to be excluded.
  396.   
  397.   
  398.   
  399.                                  - 1 -
  400.   
  401.  
  402.  MEASURE - Performance Measurement of Pascal Programs         03 Jan 79 
  403.   
  404.  How to Use AUGMENT and ANALYZE
  405.  ------------------------------ 
  406.  
  407.       Under CDC 6000/Cyber 70,170 computer systems, AUGMENT and ANALYZE 
  408.  are control statements.  Thus the following batch commands do the job: 
  409.  
  410.            FETCH(AUGMENT,ANALYZE) 
  411.            AUGMENT(the file name of your Pascal source program)
  412.            PASCAL(INTER/L-,G+)
  413.            ANALYZE. 
  414.  
  415.       The program headings for AUGMENT and ANALYZE are: 
  416.  
  417.  AUGMENT(INPUT, EXCEPT, INTER, INTER2, OUTPUT)   where:
  418.  
  419.      INPUT  is the textfile containing the Pascal source program to  be 
  420.             augmented. 
  421.  
  422.      EXCEPT is  the  textfile containing a list of names (one to a line
  423.             with no leading blanks) of procedures and functions  to  be
  424.             excluded  from measurement.  EXCEPT can be an empty file in
  425.             which case no procedures or functions will be excluded. 
  426.  
  427.      INTER  is the textfile on  which  the  augmented  version  of  the 
  428.             Pascal source program is written.
  429.  
  430.      INTER2 is  the  binary  file  on  which  only  the  names  of each 
  431.             procedure and function in  the  Pascal  source  program  is
  432.             written for use by ANALYZE.
  433.  
  434.      OUTPUT is  the  textfile  on  which  error messages are written if
  435.             problems occur during augmenting.  A report is  written  on 
  436.             OUTPUT  verifying which procedures or functions were exclu- 
  437.             ded, if any.
  438.  
  439.      The error messages from AUGMENT are: 
  440.  
  441.      *** TOO MANY PROCEDURES AND FUNCTIONS TO  AUGMENT.   (A  limit  of
  442.             2000 is imposed.)
  443.  
  444.      *** "BEGIN" EXPECTED.
  445.  
  446.      *** "END"  EXPECTED.  (There is something wrong with the statement 
  447.             part of the Pascal source program which is being augmented; 
  448.             it  began  with  some  reserved  word other than "BEGIN" or 
  449.             there weren't enough "END"s to match "BEGIN"s.) 
  450.  
  451.      *** "PROGRAM" EXPECTED.  (AUGMENT couldn't find "PROGRAM"  as  the 
  452.             first reserved word in the Pascal source program.  Possibly
  453.             the INPUT file was empty.) 
  454.  
  455.      *** UNDECLARED LABEL: xxx (AUGMENT couldn't find a label  referred 
  456.             to by a GOTO statement.)
  457.   
  458.   
  459.  
  460.                                  - 2 -
  461.   
  462.  
  463.  MEASURE - Performance Measurement of Pascal Programs         03 Jan 79 
  464.   
  465.  ANALYZE(OUTPUT, INTER2, TIMING)   where:
  466.  
  467.      OUTPUT is the textfile on which the performance measurement report
  468.             is written or alternatively the error message: 
  469.             *** TIMING FILE EMPTY.
  470.  
  471.      INTER2 is the binary file on which the names of each procedure and 
  472.             function  in  the  Pascal  source  program  was  written by
  473.             AUGMENT.
  474.  
  475.      TIMING is the binary file containing the dynamic  timing  measure- 
  476.             ments  resulting  from  execution  of  the augmented Pascal 
  477.             program. 
  478.  
  479.       Note:  The identifier "TIMING" is  added  to  the  Pascal  source 
  480.  program  by  AUGMENT  and must not appear in any procedure or function
  481.  which is to be monitored.  When you use AUGMENT  and  ANALYZE,  it  is 
  482.  probably  a  good  idea  to consider the file names INTER, INTER2, and 
  483.  TIMING reserved. 
  484.  
  485.       In summary, there are four steps to the  performance  measurement 
  486.  process:
  487.  
  488.  1) [Pascal source program] -> AUGMENT -> INTER and INTER2 
  489.                                *******
  490.  
  491.  2)               INTER -> PASCAL Compiler -> [Pascal binary program]
  492.                            ***************
  493.  3) [input data for 
  494.      Pascal program] -> Pascal binary program -> TIMING and [results
  495.                         *********************    from Pascal program] 
  496.  
  497.  4)       TIMING and INTER2 -> ANALYZE -> [performance measurement 
  498.                                *******     report]
  499.   
  500.  EXAMPLE
  501.  -------
  502.       Below  are  a  test  program,  its  augmented  version,  and  the 
  503.  performance measurement report:
  504.  
  505.       The source of the test program: 
  506.  
  507.       PROGRAM TEST(OUTPUT); 
  508.         LABEL  5; 
  509.         VAR   N: INTEGER; 
  510.  
  511.         PROCEDURE A;
  512.  
  513.           PROCEDURE B;
  514.           BEGIN  N := N + 1;
  515.             IF ODD(N DIV 2) THEN A ELSE B 
  516.           END (*B*) ; 
  517.  
  518.         BEGIN (*A*) 
  519.           N := N + 1; 
  520.   
  521.                                  - 3 -
  522.   
  523.  
  524.  MEASURE - Performance Measurement of Pascal Programs         03 Jan 79 
  525.   
  526.           IF N > 200 THEN GOTO 5; 
  527.           B 
  528.         END (*A*) ; 
  529.       BEGIN N := 0;  A;  5:  END. 
  530.   
  531.   
  532.   
  533.  
  534.       The augmented version of the test program:
  535.  
  536.        PROGRAM TEST(OUTPUT,TIMING); 
  537.          LABEL   5; 
  538.          VAR
  539.        TIMING:FILE OF PACKED RECORD I:0..2000;T:0..99999999;M:0..2 END; 
  540.           N: INTEGER; 
  541.  
  542.          PROCEDURE A; 
  543.  
  544.            PROCEDURE B; 
  545.            BEGIN
  546.        WITH TIMING^ DO BEGIN I:=   3;T:=CLOCK;M:=0 END;PUT(TIMING);
  547.          N := N + 1;
  548.              IF ODD(N DIV 2) THEN A ELSE B
  549.            ;
  550.        WITH TIMING^ DO BEGIN I:=   3;T:=CLOCK;M:=1 END;PUT(TIMING) 
  551.        END
  552.         (*B*) ; 
  553.  
  554.          BEGIN
  555.        WITH TIMING^ DO BEGIN I:=   1;T:=CLOCK;M:=0 END;PUT(TIMING);
  556.         (*A*) 
  557.            N := N + 1;
  558.            IF N > 200 THEN  BEGIN 
  559.        WITH TIMING^ DO BEGIN I:=   2;T:=CLOCK;M:=2 END;PUT(TIMING);
  560.        GOTO 5 END 
  561.        ;
  562.            B
  563.          ;
  564.        WITH TIMING^ DO BEGIN I:=   2;T:=CLOCK;M:=1 END;PUT(TIMING) 
  565.        END
  566.         (*A*) ; 
  567.        BEGIN REWRITE(TIMING); 
  568.        WITH TIMING^ DO BEGIN I:=   1;T:=CLOCK;M:=0 END;PUT(TIMING);
  569.         N := 0;  A;  5:  ;
  570.        WITH TIMING^ DO BEGIN I:=   1;T:=CLOCK;M:=1 END;PUT(TIMING) 
  571.        END
  572.        .
  573.   
  574.   
  575.   
  576.   
  577.                                  - 4 -
  578.   
  579.  
  580.  MEASURE - Performance Measurement of Pascal Programs         03 Jan 79 
  581.   
  582.       The report from ANALYZE:
  583.  
  584.   PERFORMANCE MEASUREMENT SUMMARY FOR PASCAL PROGRAM:  TEST      .
  585.  
  586.                                                  EXECUTION TIME 
  587.                        CALLS                     (MILLISECONDS) 
  588.     MODULE        TIMES    PERCENT        AVERAGE    MODULE    PERCENT
  589.      NAME         CALLED   OF TOTAL       PER CALL   TOTAL     OF TOTAL 
  590.   ----------      ------   --------       --------   ------    -------- 
  591.   A                   52     25.490           0.15        8      27.586 
  592.   B                  151     74.020           0.13       20      68.966 
  593.   TEST                 1      0.490           1.00        1       3.448 
  594.   ==========      ======   ========       ========   ======    ======== 
  595.     TOTALS           204    100.000           0.14       29     100.000 
  596.  
  597.       From the  summary  provided  by  AUGMENT  and  ANALYZE,  you  can 
  598.  identify  which  procedures  and  functions  to  improve  for  greater 
  599.  execution efficiency.  In general, it pays to  concentrate  on  proce-
  600.  dures and functions which are frequently called and take a significant 
  601.  amount of the total execution time of  the  program.   Procedures  and
  602.  functions  which  have  a  large  average execution time per call, but 
  603.  which are only called a few times are not worth worrying about. 
  604.  
  605.       If one or more procedures  or  functions  seem  to  dominate  the 
  606.  results,  it  might  be  a good idea to monitor the program with these
  607.  modules excluded from measurement.  Use the except feature provided by 
  608.  AUGMENT. 
  609.   
  610.  History
  611.  -------
  612.       AUGMENT  and  ANALYZE  were  conceived originally under the names
  613.  PROFILE and PRINRES in 1975-1976 by S.  Matwin and M.  Missala, of the 
  614.  Polish Academy of Sciences Computer Centre, PKiN, Warwaw, Poland.  The
  615.  goal of the project was to build a simple tool to measure  very  large
  616.  programs--such as the Pascal 6000 compiler itself.  A paper describing
  617.  their successful work entitled: "A Simple,  Machine  Independent  Tool
  618.  for  Obtaining Rough Measures of Pascal Programs," appeared in SIGPLAN 
  619.  Notices (11:8) August, 1976, pages 42-45.
  620.  
  621.       In 1976, Richard J.  Cichelli of  Lehigh  University  Mathematics 
  622.  Department  and the American Newspaper Publishers Association Research 
  623.  Institute, obtained the programs and documented and  distributed  them 
  624.  to the Pascal community in the United States.
  625.  
  626.       In  1977,  Herb  Rubenstein  and Andy Mickel of the University of 
  627.  Minnesota Computer Center, modified the programs for coding style  and 
  628.  to  increase  portability, fixed bugs, and improved the performance of
  629.  the programs themselves.  We also  removed  several  limitations  (the 
  630.  built-in  restrictions  regarding  the  use  of non-local GOTOs within
  631.  procedures and functions as well as the monitoring of procedures named 
  632.  NEXTCH).  See "Pascal News"  12, May, 1978, page 23. 
  633.  
  634.       The  programs are now supported with the Pascal-6000 system which 
  635.  is distributed to CDC installations around the world.
  636.   
  637.  
  638.                                  - 5 -
  639.   
  640.  
  641.  PASCODE - List Relocatable-Binary Code in Symbolic Form      03 Jan 79
  642.   
  643.         PASCODE - List Relocatable-Binary Code in Symbolic Form
  644.  
  645.                               J. P. Strait 
  646.                        University Computer Center
  647.                         University of Minnesota
  648.  
  649.               Copyright (C) University of Minnesota - 1978 
  650.  
  651.       PASCODE lists relocatable-binary code produced by the Pascal 6000 
  652.  compiler in pseudo-COMPASS form.   To  conserve  space,  one  word  of
  653.  instructions  is  printed  per line in columns which correspond to the
  654.  four parcels in central memory words.  If PASCODE is presented with  a 
  655.  Pascal  binary  which  was  not  compiled  with  post-mortem dump info 
  656.  entirely  suppressed,  it  is  able  to  differentiate  between  code, 
  657.  constants  and  post-mortem  dump  info.   If  it  is presented with a
  658.  non-Pascal binary, or one compiled with PMD  info  suppressed  (Pascal 
  659.  compiler  option P0, see the Pascal writeup), PASCODE will print every 
  660.  word in both octal and pseudo-COMPASS. 
  661.  
  662.       PASCODE prints correct pseudo-COMPASS for  Pascal  binaries,  and 
  663.  does fairly well for non-Pascal binaries.  PASCODE does not handle all
  664.  of the defined loader tables, only  those  that  the  Pascal  compiler
  665.  produces.  It does not handle more than one external reference applied
  666.  to a single address field, nor does it handle  an  external  reference
  667.  and  program  relocation  applied  to  the same address field.  Common
  668.  blocks are not handled.  Only one entry point is  recognized  in  each
  669.  relocatable  record.  Each procedure is assumed to be terminated by an 
  670.  End-Of-Record mark.
  671.  
  672.       In particular, the only loader tables that are processed are:
  673.  
  674.       3400 - PIDL - Program identification and length. 
  675.       3600 - ENTR - Entry point definitions.
  676.       4000 - TEXT - Relocatable text. 
  677.       4300 - REPL - Replication of text.
  678.       4400 - LINK - External reference linkage.
  679.       7700 - PRFX - Prefix.
  680.  
  681.       All other tables are ignored.
  682.   
  683.  
  684.       The program heading of PASCODE is:
  685.  
  686.       PROGRAM PASCODE(LGO,OUTPUT) 
  687.  
  688.  and so to decode a binary on file LGO use the control statement: 
  689.  
  690.       FETCH(PASCODE)
  691.       PASCODE.
  692.  
  693.  and to decode a binary on file ABC use the control statement:
  694.  
  695.       FETCH(PASCODE)
  696.       PASCODE(ABC)
  697.   
  698.  
  699.                                  - 1 -
  700.   
  701.  
  702.  PASCREF - CROSS REFERENCE PASCAL PROGRAMS.                   03 Jan 79 
  703.   
  704.     PASCREF -- A Cross-Reference-Listing Generator for Pascal Programs 
  705.  
  706.                                   - Andy Mickel 78/07/12. 
  707.                                   - University Computer Center 
  708.                                   - University of Minnesota
  709.  
  710.  What PASCREF Does
  711.  -----------------
  712.  
  713.       PASCREF is  a  software  tool  used  to  produce  cross-reference 
  714.  listings  of identifiers in a Pascal program.  PASCREF lists the input
  715.  program and numbers each line.  Below  the  listing  a  table  of  all 
  716.  identifiers (except reserved words) is given together with a series of 
  717.  line numbers which identify each appearance of the identifier  in  the 
  718.  program.   Generally,  the first occurrence of each identifier denotes 
  719.  the line on which it was declared.  Two exceptions to the exclusion of
  720.  reserved  words in the table are references to the symbols "LABEL" and
  721.  "GOTO".  Their  inclusion  is  useful  because  they  should  be  used 
  722.  carefully  in a Pascal program.  Any non-standard Pascal 6000 reserved 
  723.  words  also  appear  in  the  cross-reference  table.   Following  the 
  724.  cross-reference listing, a map of procedures and functions is given to 
  725.  aid their lookup in large programs. 
  726.  
  727.  Facts About PASCREF
  728.  -------------------
  729.  
  730.  1)  The listing produced is paged  to  fit  in  top-binding  folders-- 
  731.      perfect for nice "permanent" listings for reference use. 
  732.  10)  PASCREF  can  handle  programs  up to 100000 lines long and up to
  733.      approximately 1500 identifiers.
  734.  3)  The execution time for running PASCREF across the Pascal  compiler
  735.      (an 8000-line program) was 17.8 seconds on a Cyber 74. 
  736.  4)  The  memory  required  to run PASCREF is proportional to the total
  737.      number of identifiers and identifier occurrences in the program to
  738.      be  cross-referenced.   For  the  400-line PASCREF program itself,
  739.      CM20000 was sufficient. 
  740.  
  741.  How to Use PASCREF 
  742.  ------------------ 
  743.  
  744.       PASCREF is available as  a  batch  control  statement  under  CDC 
  745.  operating  systems.  Its program heading is:  XREF(INPUT,OUTPUT).  The 
  746.  general form of the PASCREF control statement is:
  747.  
  748.       PASCREF(ProgramFileName, X-RefListingFileName/ Parameters) 
  749.  
  750.       Two optional parameters are available:  "W" and "U".  U  controls
  751.  the  width  of each input line scanned:  U+ = 72, U- = 120; default is
  752.  U-.  W controls the width of the cross-reference table  written  after 
  753.  the  numbered  program listing:  W+ = 72, W- = 136; default is W-.  W- 
  754.  generates nesting  level  indicators  to  the  right  of  the  listing
  755.  annotating  "BEGIN-END", "REPEAT-UNTIL", and "CASE-END" pairs.  There- 
  756.  fore the default PASCREF control statement is: 
  757.  
  758.            PASCREF(INPUT,OUTPUT/U-,W-)
  759.   
  760.  
  761.                                  - 1 -
  762.   
  763.  
  764.  PASCREF - CROSS REFERENCE PASCAL PROGRAMS.                   03 Jan 79 
  765.   
  766.       To compile and  run  a  Pascal  program  with  a  cross-reference 
  767.  listing, use the following command sequence:
  768.  
  769.            PASCAL,,LIST.
  770.            PASCREF(LIST)
  771.            LGO. 
  772.  
  773.       PASCREF may produce the following error messages:
  774.  
  775.  1)  "TABLE FULL" (caused by too many identifiers). 
  776.  2)  "TEXT TOO LONG" (program length was more than 100000 lines).
  777.  3)  "NO  PROGRAM FOUND TO CROSS REFERENCE" (an empty file was given as
  778.      input). 
  779.  
  780.       Also a workspace overflow may result if  insufficient  memory  is 
  781.  given to PASCREF. 
  782.  
  783.  History
  784.  -------
  785.  
  786.       PASCREF  was  first  written in January, 1971 by Niklaus Wirth at
  787.  the Institut fur Informatik, E.T.H.  Zurich.  He  revised  it  several 
  788.  times  over  the  years  for inclusion with subsequent releases of the 
  789.  Pascal 6000 compiler.  The major improvement was employing a quicksort
  790.  procedure  in 1975.  The program was modified slightly by Andy Mickel,
  791.  Dan LaLiberte, and John Strait  at  the  University  of  Minnesota  to 
  792.  process  a compiler listing with line numbers and titles and to append 
  793.  a map of procedures and functions.  For more information see the book:
  794.  "Algorithms  +  Data  Structures  =  Programs,"  chapter 4, by Niklaus
  795.  Wirth, Prentice Hall, 1976.
  796.   
  797.   
  798.   
  799.   
  800.   
  801.   
  802.   
  803.   
  804.   
  805.   
  806.   
  807.   
  808.   
  809.   
  810.                                  - 2 -
  811.   
  812.  
  813.  PASVERT - Pascal Program Character Set Conversion            03 Jan 79 
  814.   
  815.            PASVERT - Pascal Program Character Set Conversion
  816.  
  817.                               J. P. Strait 
  818.                        University Computer Center
  819.                         University of Minnesota
  820.  
  821.               Copyright (C) University of Minnesota - 1978 
  822.   
  823.       Program  PASVERT reads a Pascal program written in either the CDC 
  824.  scientific character set or the CDC ASCII  subset,  and  performs  the
  825.  required  conversions to write the program in the other character set. 
  826.  It automatically supplies the appropriate "A" compiler option  as  the
  827.  first line of the newly converted Pascal source program. 
  828.   
  829.  The conversions for scientific to ASCII are-
  830.  
  831.       Pascal Symbol       Old Name            New Name
  832.       -------------       --------            --------
  833.       string delimiter    60B equivalence     70B single quote 
  834.       not equal           64B not equal           <>
  835.       open comment        65B right arrow         (* 
  836.       close comment       71B down arrow          *) 
  837.       or                  66B logical or          OR 
  838.       and                 67B logical and         AND
  839.       not                 76B logical not         NOT
  840.       pointer             70B up arrow        76B circumflex
  841.       less or equal       74B less or equal       <=
  842.       greater or equal    75B greater or equal    >=
  843.   
  844.  The conversions for ASCII to scientific are-
  845.  
  846.       Pascal Symbol       Old Name            New Name
  847.       -------------       --------            --------
  848.       string delimiter    70B single quote    60B equivalence
  849.       pointer             76B circumflex      70B up arrow
  850.   
  851.       Characters  within  comments  are  converted,  but  those  within
  852.  strings are left  alone.   PASVERT  requires  a  syntactically-correct 
  853.  (compilable) Pascal program as input.  It performs no error checking. 
  854.   
  855.  The program heading for PASVERT is- 
  856.  
  857.            PROGRAM PASVERT(INPUT+,OUTPUT+)
  858.  
  859.  and so the control statement call is-
  860.  
  861.            PASVERT(IN,OUT/+)  -or-  PASVERT(IN,OUT/-) 
  862.  
  863.  where  "IN"  is the file you want to convert, and "OUT" is the result. 
  864.  "IN" and "OUT" may not be the same actual file  name.   The  character
  865.  ('+'  or '-') after the slash selects the conversion by indicating the 
  866.   
  867.                                  - 1 -
  868.   
  869.  
  870.  PASVERT - Pascal Program Character Set Conversion            03 Jan 79 
  871.   
  872.  appropriate setting of the "A" compiler option for  the  output  file.
  873.  That  is,  '+'  selects a conversion from scientific to ASCII, and '-' 
  874.  selects a conversion from ASCII to scientific.  The default  value  of 
  875.  this option is '+'.
  876.   
  877.       The  input  file  is rewound before processing unless its name is
  878.  actually "INPUT".  The output file is not rewound.  Conversion is done
  879.  until  an  end-of-file  mark  is reached, but all logical record marks
  880.  within that file are preserved.
  881.   
  882.   
  883.   
  884.   
  885.   
  886.   
  887.   
  888.   
  889.   
  890.   
  891.   
  892.   
  893.   
  894.   
  895.   
  896.   
  897.   
  898.   
  899.   
  900.   
  901.   
  902.   
  903.   
  904.   
  905.                                  - 2 -
  906.   
  907.  
  908.  PRETTY - Pascal Prettyprinting Program                       03 Jan 79 
  909.   
  910.              PRETTY - Pascal Prettyprinting Program 
  911.  
  912.                              - Jon Hueras and 
  913.                                Henry Ledgard 76/08/01.
  914.                              - Rick L. Marcus 78/09/15. 
  915.  
  916.  What PRETTY Does 
  917.  ---------------- 
  918.  
  919.       PRETTY takes as input a Pascal program or  program  fragment  and
  920.  reformats it according to a standard set of prettyprinting rules.  The
  921.  prettyprinted program is given as output.  PRETTY makes no attempt  to
  922.  detect  or correct syntactic errors in your program.  However, syntac-
  923.  tic errors may result in erroneous prettyprinting.
  924.  
  925.       PRETTY differs from some other prettyprinting programs in that it 
  926.  does  not  reformat your program "right down to every last semicolon."
  927.  Such a philosophy requires formatting everything in  a  rigid  fashion
  928.  which  is  bound to be displeasing, or else it must provide you with a 
  929.  voluminous set of "options."  Furthermore, such a scheme must do  full
  930.  syntax  analysis of the program which means that it must be completely 
  931.  written and compilable.  If you wish to prettyprint  a  program  still 
  932.  under development, then you are out of luck.
  933.  
  934.       PRETTY,  on  the  other  hand, implements a strategy which states 
  935.  that it is not necessary to  impose  more  than  a  "minimum"  set  of
  936.  restrictions,  and  the  prettyprinter should yield to your discretion 
  937.  beyond this minimum.  PRETTY preserves blank lines  and  extra  spaces 
  938.  you  insert  in  the  program as input, besides adding blank lines and 
  939.  extra spaces according to the rules for prettyprinting given below. 
  940.  
  941.    General prettyprinting rules: 
  942.  
  943.  1.  Spaces and blank lines already in your program  are  preserved  by 
  944.    PRETTY,  which  adds (but does not subtract) blank lines and spaces. 
  945.    You can improve the readability of your programs by taking advantage
  946.    of this feature.
  947.  
  948.  2.  All statements and declarations begin on separate lines.
  949.  
  950.  3.   No  input line may be longer than 80 characters.  Any output line
  951.    longer than 80 characters is continued on a separate line. 
  952.  
  953.  4.  The keywords "BEGIN", "END", "REPEAT", and "RECORD" are forced  to 
  954.    stand  on  lines  by  themselves (or possibly followed by supporting 
  955.    comments).   In  addition,  the  "UNTIL"  clause  of  "REPEAT-UNTIL" 
  956.    statement is forced to start on a new line.
  957.  
  958.  5.  A blank line is forced before the keywords "PROGRAM", "PROCEDURE", 
  959.    "FUNCTION", "LABEL", "CONST", "TYPE", and "VAR".
  960.  
  961.  6.  A space is forced before and  after  the  symbols  ":="  and  "=". 
  962.    Additionally,  a  space  is  forced after the symbol ":".  Note that 
  963.    only "="s in declarations are formatted;  "="s  in  expressions  are 
  964.    ignored.
  965.   
  966.  
  967.                                  - 1 -
  968.   
  969.  
  970.  PRETTY - Pascal Prettyprinting Program                       03 Jan 79 
  971.   
  972.    Indentation rules:
  973.  
  974.  1.   The  body of a declaration is indented from the "LABEL", "CONST",
  975.    "TYPE", or "VAR" keyword which heads it.
  976.  
  977.  2.  The bodies of "BEGIN-END", "REPEAT-UNTIL",  "WHILE",  "WITH",  and
  978.    "CASE"  statements,  as  well  as "RECORD-END" structures and "CASE"
  979.    variants (to one level) are indented from keywords which head them.
  980.  
  981.  3.  An "IF-THEN-ELSE" statement is indented as follows: 
  982.  
  983.          IF <expression>
  984.             THEN
  985.                <statement> 
  986.             ELSE
  987.                <statement> 
  988.  
  989.  How to Use PRETTY
  990.  -----------------
  991.  
  992.       PRETTY is available as a  KRONOS/NOS  control  statement  on  CDC 
  993.  6000/Cyber 70,170 computer systems.  Two file names are required:  the 
  994.  local file name of program to be prettyprinted,  and  the  local  file 
  995.  name for the prettyprinted listing.  The general form is: 
  996.  
  997.                          PRETTY(myprog,newprog)
  998.  
  999.  The parameters  "myprog"  and  "newprog"  are  optional  but  must  be 
  1000.  specified  in  the order given.  If "myprog" is omitted, the filename,
  1001.  INPUT, is assumed.  If "newprog" is omitted, the filename, OUTPUT,  is
  1002.  assumed.   Data on INPUT is by convention from cards or an interactive 
  1003.  terminal; data on OUTPUT goes to the line printer or to an interactive
  1004.  terminal.  PRETTY formats only one record of the file named INPUT. 
  1005.  
  1006.                                ***NOTE*** 
  1007.  
  1008.       You must delete line numbers from your program if you wish to use 
  1009.  PRETTY.   Use  your favorite text editor.  If the line numbers are not
  1010.  deleted the result will not be "pretty," nor will it compile. 
  1011.  
  1012.  When to Use PRETTY
  1013.  ------------------ 
  1014.  
  1015.       PRETTY is especially useful  to  reformat  a  Pascal  program  or
  1016.  program  fragment  that  you  have  typed without regard to formatting 
  1017.  (such as entering every line left-justified to  save  time).   Because 
  1018.  the  program  need  not  be syntactically correct, PRETTY provides the 
  1019.  fastest means of obtaining a more readable version of your program.
  1020.  
  1021.       PRETTY is best used to prettyprint a Pascal program already on  a 
  1022.  file  or  punched  on cards.  PRETTY changes neither the cards nor the 
  1023.  file used as input.  Prettyprinting a program line-by-line  as  it  is 
  1024.  entered at a terminal is considerably less useful. 
  1025.   
  1026.   
  1027.  
  1028.                                  - 2 -
  1029.   
  1030.  
  1031.  PRETTY - Pascal Prettyprinting Program                       03 Jan 79 
  1032.   
  1033.  Examples
  1034.  -------- 
  1035.  
  1036.  For Interactive Processing: 
  1037.  
  1038.  1.  A  Pascal  program  (or  fragment) is on the file "myprog" and the
  1039.      desired prettyprinted listing is to be on the file "newprog": 
  1040.  
  1041.       old,myprog -or- get,myprog  (if myprog is not already a local 
  1042.       x,rfl,20000                                             file) 
  1043.       x,pretty(myprog,newprog)
  1044.  
  1045.      "newprog" is now the prettyprinted version of myprog. 
  1046.  
  1047.  For Batch Processing: 
  1048.  
  1049.  2.  A program is on cards (file INPUT) and the  prettyprinted  program 
  1050.      is to be on the printer (file OUTPUT).  The command sequence is:
  1051.  
  1052.       JOB statement. 
  1053.       USER statement.
  1054.       PRETTY. 
  1055.       7-8-9  end of record 
  1056.        Pascal program 
  1057.       6-7-8-9  end of information 
  1058.  
  1059.  3.  In  the  same  run  as  a compile and execute, a Pascal program is 
  1060.      prettyprinted:
  1061.  
  1062.       JOB statement. 
  1063.       USER statement.
  1064.       PRETTY,,TEMP.  ("TEMP" here directs PRETTY to put the pretty-
  1065.                              printed results on a file named TEMP.) 
  1066.       PASCAL,TEMP.
  1067.       LGO.
  1068.       7-8-9 
  1069.        Pascal Program
  1070.       7-8-9 
  1071.        data, if any
  1072.       6-7-8-9 
  1073.  
  1074.  History
  1075.  -------
  1076.  
  1077.       PRETTY prettyprints a Pascal program or program fragment given as
  1078.  input.   It was originally named PRETTYPRINT and was written in Pascal 
  1079.  by Jon Hueras and  Henry  Ledgard,  University  Computing  Center  and
  1080.  Computer and Information Science Dept., University of Massachusetts at 
  1081.  Amherst, in August, 1976.  (See "An Automatic Formatting  Program  for 
  1082.  Pascal",  by  Jon Hueras and Henry Ledgard, Pascal Newsletter  6, page
  1083.  70, November, 1976.)
  1084.  
  1085.       Small corrections were made to PRETTY by Charles  Fischer,  Dept. 
  1086.  of  Computer  Science,  University  of  Wisconsin,  Madison,  in 1977. 
  1087.  PRETTY was modified for CDC-6000 Pascal by Rick L. Marcus,  University 
  1088.  Computer Center, University of Minnesota, in September, 1978. 
  1089.   
  1090.                                  - 3 -
  1091.   
  1092.  
  1093.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1094.   
  1095.                     PASCAL PROGRAM FORMATTER
  1096.  
  1097.                                - Michael N. Condict 1975 and 1978. 
  1098.                                - Rick L. Marcus 78/11/24. 
  1099.                                - Andy Mickel 78/12/01.
  1100.  
  1101.  What Spruce Does
  1102.  ---------------- 
  1103.  
  1104.       Spruce is a flexible prettyprinter for Pascal programs.  It takes
  1105.  as input a syntactically-correct Pascal program and produces as output
  1106.  an  equivalent  but reformatted Pascal program.  The resulting program 
  1107.  consists of the same sequence of Pascal symbols and comments, but they
  1108.  are  rearranged  with  respect  to  line  boundaries  and  columns for
  1109.  readability.
  1110.  
  1111.       Spruce  maintains  consistent  spacing  between  symbols,  breaks
  1112.  control and data structures onto new lines if necessary, indents lines
  1113.  to reflect the syntactic level of  statements  and  declarations,  and 
  1114.  more.   Miscellaneous  features  such  as  supplying  line-numbers and
  1115.  automatic comments, or deleting all unnecessary blanks to save  space, 
  1116.  are described below.
  1117.  
  1118.       The  flexibility  of  Spruce  is  accomplished by allowing you to
  1119.  supply various directives (options) which override the default values.
  1120.  Rather than being a rigid prettyprinter which decides for you how your 
  1121.  program is to be formatted,  you  have  the  ability  to  control  how
  1122.  formatting  is  done.   Not only can prettyprinter directives be given
  1123.  prior to execution ,but also  during  execution  through  the  use  of
  1124.  directives embedded in your program.
  1125.  
  1126.       Experience  with  Spruce over the last three years has shown that
  1127.  most users can find a set of values for the directives  which  produce 
  1128.  satisfactory results.  The default values are typical. 
  1129.   
  1130.  How To Use Spruce
  1131.  -----------------
  1132.  
  1133.       Spruce  is  available  as  a  KRONOS/NOS control statement on CDC
  1134.  6000/Cyber 70,170 computer  systems.   Two  parameters  are  required: 
  1135.  "source",  which  is  a  correct  (compilable)  Pascal  program  to be
  1136.  prettyprinted, and "list", which is to be the reformatted  version  of 
  1137.  the source program.  The general form is: 
  1138.  
  1139.            SPRUCE(source,list)
  1140.  
  1141.  or,  if  you wish to supply the initial values of Spruce directives on 
  1142.  the control statement:
  1143.  
  1144.            SPRUCE(source,list/FormatterDirectiveList)
  1145.  
  1146.  See the section  below  for  typical  command  sequences  for  running
  1147.  Spruce. 
  1148.  
  1149.       Directives  to  Spruce  may  always  be  specified in the program 
  1150.   
  1151.                                  - 1 -
  1152.   
  1153.  
  1154.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1155.   
  1156.  itself inside comments with a special syntax.  Thus the first line  of
  1157.  a  program  is  an  ideal  spot  for  a comment containing directives. 
  1158.  Subsequent use of embedded directives allows you to change the kind of 
  1159.  prettyprinting  for different sections of your program.  The syntax of
  1160.  these special comments is given  below  (The  syntax  is  given  using 
  1161.  "EBNF"--Extended  Backus-Naur  Form--see Communications ACM, November,
  1162.  1977, page 822.):
  1163.  
  1164.  DirectiveComment = "(*" DirectiveList "*)" | 
  1165.                "(*$" CompilerOptionList CommentText DirectiveList "*)".
  1166.  
  1167.    DirectiveList = "[" Directive {"," Directive} "]" CommentText. 
  1168.  
  1169.        Directive = Letter Setting. 
  1170.  
  1171.           Letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | 
  1172.                    "I" | "L" | "N" | "P" | "R" | "S" | "W". 
  1173.  
  1174.          Setting = Switch | Value | Range. 
  1175.  
  1176.           Switch = "+" | "-" .
  1177.  
  1178.            Value = "=" UnsignedInteger.
  1179.  
  1180.            Range = "=" UnsignedInteger "-" UnsignedInteger ["<" | ">"].
  1181.  
  1182.  UnsignedInteger = Digit{Digit}. 
  1183.  
  1184.      CommentText = {Any character except "]" or close-comment}. 
  1185.  
  1186.  Note:   As  defined  above,  a  Directive  may  be  within  a  comment 
  1187.  specifying  a Pascal CompilerOptionList.  On most implementations this
  1188.  is a "$" followed by a series of letters  and  values  ("+",  "-",  or 
  1189.  digits), separated by commas.  See your local manual.
  1190.  
  1191.  Examples of DirectiveComments: 
  1192.  
  1193.       (*[A=15, E=3, N=1,1<]*)  -  good for publication quality.
  1194.       (*[G=0, W=1-100, C+]*)  -  good for compact storage. 
  1195.       (*$U+ [R=1-72, I=2]*)  - an example of a DirectiveList with a 
  1196.                                CompilerOptionList. 
  1197.   
  1198.  Directives to Spruce 
  1199.  -------------------- 
  1200.  
  1201.  A=n  Align declarations.
  1202.           The  A  directive  forces  the  alignment  of  ":" and "=" in 
  1203.           declarations.  If A is set to a value greater than 0, then  n 
  1204.           should  be  equal  to  the maximum identifier length for that 
  1205.           section of your program.  The A directive visually  clarifies 
  1206.           the declaration part of your program.  See example below.
  1207.           Default: A=0 (no alignment). 
  1208.  
  1209.  B+ or B-  Bunch statements and declarations reasonably. 
  1210.           B+  will  place  as  many statements or declarations onto one 
  1211.   
  1212.                                  - 2 -
  1213.   
  1214.  
  1215.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1216.   
  1217.           line as will  fit  within  the  specified  write  margins  (W
  1218.           directive) subject to readability constraints.  Bunching (B+)
  1219.           when the display is off (D-) has no effect.  In  general,  B+ 
  1220.           saves  paper  and  prevents your program from becoming overly 
  1221.           stretched in the vertical direction.  See example below. 
  1222.           Default:  B- (one statement or statement part per line).
  1223.  
  1224.  C+ or C-  Fully Compress program.
  1225.           C+ removes all non-essential blanks, end-of-lines,  and  com- 
  1226.           ments  from  your program.  A compilable, packed program will
  1227.           be written within the specified write margins (W  directive). 
  1228.           The  number of spaces specified by the G directive will still 
  1229.           be written between symbols.  C+  might  save  some  space  on
  1230.           long-term  storage  media  such  as  disk;  you might store a 
  1231.           program in compressed form and expand it later  by  reformat-
  1232.           ting with C-. 
  1233.           Default:  C-. 
  1234.  
  1235.  D+ or D-  Turn Display on or off.
  1236.           D  allows you to selectively display portions of your program 
  1237.           during prettyprinting.  Therefore, D must be switched on  and
  1238.           off  with  directives  which are appropriately placed in your 
  1239.           program.  D is perhaps useful to obtain program fragments for
  1240.           publication  (such  as one or more procedures) without having
  1241.           to print the whole program. 
  1242.           Default:  D+. 
  1243.  
  1244.  E=n  Supply END comments.
  1245.           The E directive generates comments  after  "END"  symbols  if 
  1246.           none  are  already  there.   Common Pascal coding styles fre- 
  1247.           quently employ these comments.  E=1  creates  comments  after 
  1248.           the  "END"  symbol  in  compound  statements which are within
  1249.           structured statements, as well as those  constituting  proce- 
  1250.           dure  and  function  bodies.   The  comments  take  the form: 
  1251.           (*StatementPart*) or (*ProcedureName*).  E=2 creates comments
  1252.           after  the  "BEGIN"  and "END" symbols constituting procedure
  1253.           and function bodies only.  E=0 creates no  comments  at  all.
  1254.           E=3 means E=1 and E=2.  See example below.
  1255.           Default:  E=2.
  1256.  
  1257.  F+ or F-  Turn Formatting (prettyprinting) on or off. 
  1258.           F allows you to format selected portions of your program.  F- 
  1259.           causes Spruce to copy the  input  program  directly  with  no 
  1260.           changes.  Therefore by switching F on and off with directives 
  1261.           which are appropriately  placed  in  your  program,  you  can 
  1262.           preserve  text  which  is already properly formatted (such as
  1263.           comments).
  1264.           Default:  F+ (of course!).
  1265.  
  1266.  G=n  Specify symbol Gap.
  1267.           The G  directive  determines  the  number  of  spaces  placed 
  1268.           between  Pascal  symbols  during  prettyprinting.   G=0 still 
  1269.           places one space between two identifiers and reserved  words.
  1270.           The symbols [ ] ( ) , and : are handled independently of G.
  1271.           Default:  G=1.
  1272.   
  1273.  
  1274.                                  - 3 -
  1275.   
  1276.  
  1277.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1278.   
  1279.  I=n  Specify Indent tab.
  1280.           I indents each nesting level of statements and declarations a
  1281.           given number of columns.  Using  I=2  or  I=1  helps  prevent 
  1282.           excessively-narrow  lines  within the specified write margins 
  1283.           (W directive) where there are heavily-nested constructs. 
  1284.           Default:  I=3.
  1285.  
  1286.  L=n  Specify Line-wraparound indent tab.
  1287.           L determines the indentation of the remainder  of  statements 
  1288.           or declarations which are too long to fit on one line. 
  1289.           Default:  L=3.
  1290.  
  1291.  N=x-y< or N=x-y>  Generate line-numbers on the left or right.
  1292.           The  N  directive  indicates the starting line-number (x) and
  1293.           the increment (y) for each succeeding line-number.  If y >  0 
  1294.           then  line-numbers  are  written  outside the specified write
  1295.           margins for the formatted program in sequential order  start-
  1296.           ing  at  x; y = 0 shuts off line-numbering.  "<" writes up to 
  1297.           4-digit, right-justified line-numbers together with a  trail- 
  1298.           ing  space  to  the  left  of each line.  ">" writes 6-digit, 
  1299.           zero-filled line-numbers to the right of  each  line.     Use
  1300.           the N directive along with the W directive.
  1301.           Default:  N=0-0> (no line-numbers).
  1302.  
  1303.  P=n  Specify spacing between Procedure and function declarations.
  1304.           The  P  directive  determines the number of blank lines to be 
  1305.           placed between  procedure  and  function  declarations.   n>2 
  1306.           makes procedures and functions visually stand out. 
  1307.           Default:  P=2.
  1308.  
  1309.  R=x-y  Specify Read margins. 
  1310.           The  R directive indicates which columns are significant when 
  1311.           Spruce reads from input file.   R  allows  Spruce  to  accept 
  1312.           files  which  have line-numbers in the first (x-1) columns or
  1313.           after the yth column.
  1314.           Default:  R=1-999 (large enough to  read  to  end-of-line  in 
  1315.           most cases). 
  1316.  
  1317.  S=n  Specify Statement separation.
  1318.           The  S  directive  determines  the  number  of spaces between
  1319.           statements bunched on the same line by  the  use  of  the  B+
  1320.           directive.   Note that this directive is only in effect if B+
  1321.           is used.
  1322.           Default:  S=3.
  1323.  
  1324.  W=x-y  Specify Write margins. 
  1325.           The W directive indicates which columns are used for  writing
  1326.           the reformatted program on the output file.  Any line-numbers
  1327.           generated (N directive) are written outside these margins. 
  1328.           Default:  W=1-72. 
  1329.   
  1330.   
  1331.   
  1332.   
  1333.                                  - 4 -
  1334.   
  1335.  
  1336.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1337.   
  1338.  Examples
  1339.  -------- 
  1340.  
  1341.  The A Directive
  1342.  ---------------
  1343.  
  1344.  Here is a sample program fragment before using Spruce:
  1345.  
  1346.            PROGRAM SAMPLE(OUTPUT);
  1347.            CONST A=6; ABC='LETTERS'; THREE=3; 
  1348.            TYPE RANGE=1..6; 
  1349.            COLOUR=(RED,BLUE); 
  1350.            VAR
  1351.            I,I2,I33,I444,I5555:RANGE; 
  1352.            YES,NO,MAYBE:BOOLEAN;
  1353.            BEGIN END. 
  1354.  
  1355.  Here is the output from Spruce with all defaults set: 
  1356.  
  1357.            PROGRAM SAMPLE(OUTPUT);
  1358.  
  1359.            CONST
  1360.               A = 6;
  1361.               ABC = 'LETTERS';
  1362.               THREE = 3;
  1363.  
  1364.            TYPE 
  1365.               RANGE = 1 .. 6; 
  1366.               COLOUR =
  1367.                  (RED, BLUE); 
  1368.  
  1369.            VAR
  1370.               I, I2, I33, I444, I5555: RANGE; 
  1371.               YES, NO, MAYBE: BOOLEAN;
  1372.  
  1373.            BEGIN
  1374.            END (*SAMPLE*).
  1375.  
  1376.  Here is the output from Spruce  having  added  a  line  with  the  A=5 
  1377.  directive:
  1378.  
  1379.            (*[A=5] ALIGN DECLARATIONS.  *)
  1380.            PROGRAM SAMPLE(OUTPUT);
  1381.  
  1382.            CONST
  1383.                  A = 6; 
  1384.                ABC = 'LETTERS'; 
  1385.              THREE = 3; 
  1386.  
  1387.            TYPE 
  1388.              RANGE = 1 .. 6;
  1389.             COLOUR = (RED, BLUE); 
  1390.  
  1391.            VAR
  1392.                   I,
  1393.                  I2,
  1394.   
  1395.                                  - 5 -
  1396.   
  1397.  
  1398.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1399.   
  1400.                 I33,
  1401.                I444,
  1402.               I5555: RANGE; 
  1403.                 YES,
  1404.                  NO,
  1405.               MAYBE: BOOLEAN; 
  1406.  
  1407.            BEGIN
  1408.            END (*SAMPLE*).
  1409.  
  1410.  The B Directive
  1411.  ---------------
  1412.  
  1413.  If the input to Spruce is: 
  1414.  
  1415.            PROGRAM T(OUTPUT); 
  1416.            CONST INCREMENT = 5; 
  1417.            VAR I,J,N:INTEGER; 
  1418.            BEGIN
  1419.            N:=0;
  1420.            J:=3; I:=SQR(N); N:=N+INCREMENT; 
  1421.            IF N>73 THEN BEGIN DOTHIS; DOTHAT END ;
  1422.            IF N>5 THEN  IF J>6 THEN  DOSOMETHINGELSE; 
  1423.            END. 
  1424.  
  1425.  then the output from Spruce (using the default, B-) is: 
  1426.  
  1427.            PROGRAM T(OUTPUT); 
  1428.  
  1429.            CONST
  1430.               INCREMENT = 5;
  1431.  
  1432.            VAR
  1433.               I, J, N: INTEGER; 
  1434.  
  1435.            BEGIN
  1436.               N := 0; 
  1437.               J := 3; 
  1438.               I := SQR(N);
  1439.               N := N + INCREMENT; 
  1440.               IF N > 73 THEN
  1441.                  BEGIN
  1442.                     DOTHIS; 
  1443.                     DOTHAT
  1444.                  END; 
  1445.               IF N > 5 THEN 
  1446.                  IF J > 6 THEN
  1447.                     DOSOMETHINGELSE;
  1448.            END (*T*). 
  1449.  
  1450.  and the output from Spruce with B directives embedded is: 
  1451.  
  1452.            (*[B+] BUNCH STATEMENTS.  *) 
  1453.            PROGRAM T(OUTPUT); 
  1454.  
  1455.            CONST
  1456.   
  1457.                                  - 6 -
  1458.   
  1459.  
  1460.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1461.   
  1462.               INCREMENT = 5;
  1463.  
  1464.            VAR
  1465.               I, J, N: INTEGER; 
  1466.  
  1467.            BEGIN
  1468.               N := 0;   J := 3;   I := SQR(N);   N := N + INCREMENT;
  1469.               IF N > 73   THEN BEGIN DOTHIS;   DOTHAT END;
  1470.            (*[B-] UNBUNCH.  *)
  1471.               IF N > 5 THEN 
  1472.                  IF J > 6 THEN
  1473.                     DOSOMETHINGELSE;
  1474.            END (*T*). 
  1475.  
  1476.  The E Directive
  1477.  ---------------
  1478.  
  1479.  Suppose that a Pascal program fragment looked like: 
  1480.  
  1481.            PROCEDURE SAMPLE;
  1482.              PROCEDURE INNER; 
  1483.              BEGIN END; 
  1484.            BEGIN
  1485.              IF X=3 THEN
  1486.                        BEGIN X:=1; I:=I+1 
  1487.                        END
  1488.                     ELSE
  1489.                        BEGIN X:=X+I; I:=0 
  1490.                        END; 
  1491.              WHILE (CH<>'X') AND FLAG1 DO 
  1492.                BEGIN I:=I+3; INNER END; 
  1493.            END; 
  1494.  
  1495.  then using Spruce with E=3 produces: 
  1496.  
  1497.            PROCEDURE SAMPLE;
  1498.   
  1499.               PROCEDURE INNER;
  1500.  
  1501.                  BEGIN
  1502.                  END (*INNER*); 
  1503.   
  1504.               BEGIN (*SAMPLE*)
  1505.                  IF X = 3 
  1506.                  THEN 
  1507.                     BEGIN 
  1508.                        X := 1;
  1509.                        I := I + 1 
  1510.                     END (*IF*)
  1511.                  ELSE 
  1512.                     BEGIN 
  1513.                        X := X + I;
  1514.                        I := 0 
  1515.                     END (*ELSE*); 
  1516.   
  1517.                                  - 7 -
  1518.   
  1519.  
  1520.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1521.   
  1522.                  WHILE (CH <> 'X') AND FLAG1 DO 
  1523.                     BEGIN 
  1524.                        I := I + 3;
  1525.                        INNER
  1526.                     END (*WHILE*);
  1527.               END (*SAMPLE*); 
  1528.   
  1529.  How Spruce Works
  1530.  ---------------- 
  1531.  
  1532.       Spruce  parses your program by performing syntax analysis similar
  1533.  to the Pascal compiler:  recursive descent within nested  declarations 
  1534.  and  statements.   It  gathers  characters  into a buffer in which the 
  1535.  indenting count of each character is maintained.  The  characters  are 
  1536.  being continually emptied from the buffer as new ones are added.
  1537.  
  1538.       Spruce  has limited error-recovery facilities, and no results are
  1539.  guaranteed if a syntactically-incorrect program is supplied as input. 
  1540.  
  1541.       The bane of  most  Pascal  prettyprinters  is  the  treatment  of
  1542.  comments.   Spruce  considers  them in the context of a declaration or 
  1543.  statement.  Therefore using comments like: 
  1544.  
  1545.            CONST  LS=6 (*LINESIZE*);
  1546.  
  1547.  is a good idea because Spruce will carry the comment  along  with  the 
  1548.  declaration.  Similarly:
  1549.  
  1550.            BEGIN (* 'Z' < CH <= ' ' *)
  1551.  
  1552.  is also okay.
  1553.  
  1554.       Stand-alone  comments  however,  receive rough treatment.  Spruce 
  1555.  always left-justifies the first line of such comments and places it on 
  1556.  a separate line.  See the F directive.  Thus:
  1557.  
  1558.            CONST  LS=6; (*LINESIZE*)
  1559.  
  1560.  will be reformatted as: 
  1561.  
  1562.            CONST
  1563.               LS = 6; 
  1564.            (*LINESIZE*) 
  1565.  
  1566.       Proper  treatment  of  comments  is  certainly  an area of future
  1567.  development for Spruce. 
  1568.   
  1569.   
  1570.   
  1571.   
  1572.   
  1573.  
  1574.                                  - 8 -
  1575.   
  1576.  
  1577.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1578.   
  1579.  Command Sequences
  1580.  -----------------
  1581.  
  1582.      For Interactive Processing: 
  1583.  
  1584.  1.  A Pascal program is on  the  file  "myprog",  and  the  spruced-up 
  1585.      listing is to be on the file "newprog": 
  1586.  
  1587.          old,myprog -or- get,myprog  (if "myprog" is not 
  1588.                                       already a local file)
  1589.          x,rfl,20000
  1590.          x,spruce,myprog,newprog
  1591.          save,newprog
  1592.  
  1593.      "newprog" is now the spruced-up version of "myprog".
  1594.  
  1595.  2.  Rather  than  embedding directives into your program to change the 
  1596.      default values, you desire to place them on the control statement: 
  1597.  
  1598.          x,spruce,myprog,newprog/b+,s=2,i=2
  1599.   
  1600.      For Batch Processing: 
  1601.  
  1602.  3.  A  program  is on cards (file INPUT) and the spruced-up program is 
  1603.      to go to the printer (file OUTPUT).  The command sequence is: 
  1604.  
  1605.          Job Statement. 
  1606.          USER Statement.
  1607.          SPRUCE.
  1608.          7-8-9  end-of-record
  1609.  
  1610.             Pascal program
  1611.  
  1612.          6-7-8-9  end-of-information
  1613.  
  1614.  4.  In the same run as a compile and  execute,  a  Pascal  program  is 
  1615.      spruced-up: 
  1616.  
  1617.          Job Statement. 
  1618.          USER Statement.
  1619.          SPRUCE,,TEMP.  ("TEMP" here directs SPRUCE to put the pretty- 
  1620.                                 printed results on a file named TEMP.)
  1621.          PASCAL,TEMP. 
  1622.          LGO. 
  1623.          7-8-9  end-of-record
  1624.  
  1625.             Pascal program
  1626.  
  1627.          7-8-9  end-of-record
  1628.  
  1629.             data, if any 
  1630.  
  1631.          6-7-8-9  end-of-information
  1632.   
  1633.   
  1634.                                  - 9 -
  1635.   
  1636.  
  1637.  SPRUCE - Pascal Program Formatter                            03 Jan 79
  1638.   
  1639.       Spruce issues the following error messages: 
  1640.  
  1641.  1.  " *** 'PROGRAM' EXPECTED." 
  1642.       The  Pascal  program you fed to Spruce did not contain a standard
  1643.  Pascal program declaration. 
  1644.  
  1645.  2.  " *** ERRORS FOUND IN PASCAL PROGRAM." 
  1646.       Your program is syntactically incorrect.  The output from  Spruce
  1647.  probably  does  not contain all of the text from your input file.  The
  1648.  cause could be any syntactic error, most  commonly  unmatched  "BEGIN- 
  1649.  END"  pairs, or the lack of semicolons, string quotation marks, or the
  1650.  final period. 
  1651.  
  1652.  3.  " *** STRING TOO LONG."
  1653.       Your program contains a  character  string  (including  both  the 
  1654.  quotes) which is wider than the specified write margins (W directive).
  1655.  
  1656.  4.  " *** NO PROGRAM FOUND TO FORMAT." 
  1657.       The input file given to Spruce is empty.
  1658.   
  1659.  History
  1660.  -------
  1661.  
  1662.       Spruce was originally written under the name "Format" in 1975  by 
  1663.  Michael  Condict  as  a  class  project in a Pascal programming course 
  1664.  taught by Richard Cichelli at Lehigh University using CDC-6000 Pascal.
  1665.  After that, making improvements and adding directives became, tempora- 
  1666.  rily, an obsession with the author (note limited usefulness of  the  D 
  1667.  directive).  Fortunately, the program eventually stabilized and is now
  1668.  in general use by Pascal programmers at Lehigh  University  and  other 
  1669.  institutions.   After graduation the author transported Format in 1977
  1670.  to a PDP-11 running under the Swedish Pascal compiler and RSX-11  with 
  1671.  a total effort of 2 days.
  1672.  
  1673.       Spruce  was  modified  for  inclusion  with Release 3 of CDC-6000 
  1674.  Pascal by Rick L. Marcus and Andy Mickel, University Computer  Center,
  1675.  University of Minnesota, in November, 1978.
  1676.   
  1677.   
  1678.   
  1679.   
  1680.   
  1681.   
  1682.   
  1683.   
  1684.   
  1685.   
  1686.                                  - 10 - 
  1687.   
  1688.  
  1689.  WRITE - A Writeup-Oriented Character Set Translator          03 Jan 79 
  1690.   
  1691.           WRITE - A Writeup-Oriented Character Set Translator.
  1692.  
  1693.                               J. P. Strait 
  1694.                        University Computer Center
  1695.                         University of Minnesota
  1696.  
  1697.               Copyright (C) University of Minnesota - 1978 
  1698.   
  1699.       WRITE converts the Pascal 6000 writeups to any of  a  variety  of
  1700.  destination  character  sets  and  output  devices.   The  Pascal 6000
  1701.  writeups are maintained in CDC 6/12 ASCII character set  and  use  the 
  1702.  full  ASCII  character  set.  These writeups may be converted by using
  1703.  the "WRITE" program to be compatible with  the  character  set(s)  and
  1704.  output device(s) available at your site. 
  1705.   
  1706.  The WRITE control statement has the following form: 
  1707.  
  1708.            FETCH(WRITE) 
  1709.            WRITE(input,output/options)
  1710.  
  1711.  the  options are keywords which define various output characteristics. 
  1712.  They are organized into 5 main groups.
  1713.   
  1714.            Main character set type:
  1715.            ------------------------ 
  1716.  ASC     - CDC ASCII subset character set (TERM,TTY in KRONOS  and  NOS
  1717.            terminology).  See APPENDIX below. 
  1718.  SCI     - CDC  scientific  character  set (TERM,TTYD in KRONOS and NOS
  1719.            terminology). 
  1720.  A95     - 8-in-12 bit ASCII - characters are printed as  actual  ASCII
  1721.            values,  one in each 12-bit byte.  The upper bit in the byte
  1722.            is always set.  This form corresponds to SCOPE and NOS/BE 96 
  1723.            character "IC=ASCII" character set. 
  1724.   
  1725.            Destination printer type: 
  1726.            -------------------------
  1727.  LPT     - Line  printer.   Uses  carriage control characters '1', '0', 
  1728.            and '+'.
  1729.  TELEX   - Interactive terminal under KRONOS and NOS.  Carriage control 
  1730.            characters  are  expanded  and  ASCII "CR" is used for over-
  1731.            printing.
  1732.  INTRCOM - Interactive  terminal  under  SCOPE  and  NOS/BE.   Carriage
  1733.            control  characters  are  expanded but '+' is used for over- 
  1734.            printing.
  1735.   
  1736.            Underlining ability:
  1737.            -------------------- 
  1738.  ULN     - Underlining is possible on the output device. 
  1739.  NOULN   - Underlining is not possible on the output device.
  1740.   
  1741.   
  1742.                                  - 1 -
  1743.   
  1744.  
  1745.  WRITE - A Writeup-Oriented Character Set Translator          03 Jan 79 
  1746.   
  1747.            63/64 character set (ignored for A95 mode):
  1748.            -------------------------------------------
  1749.  63      - The installation character set is 63 character set.
  1750.  64      - The installation character set is 64 character set.
  1751.   
  1752.            KRONOS and NOS 6/12 character set (ignored for A95 mode): 
  1753.            ---------------------------------------------------------
  1754.  NORMAL  - Only 6-bit display code will be used.  This is required  for
  1755.            upper-case-only line printers.
  1756.  EXTEND  - The  extended  6/12  ASCII characters are used.  This option 
  1757.            should not be used under SCOPE or NOS/BE.
  1758.   
  1759.  The default control statement is: 
  1760.  
  1761.            WRITE(INPUT,OUTPUT/ASC,LPT,EXTEND,63,ULN)
  1762.  
  1763.  although the default options may be changed to be more appropriate  to 
  1764.  a particular computer system. 
  1765.   
  1766.                           *** *** *** *** *** 
  1767.   
  1768.       The input to WRITE is assumed to be a  line-printer  ready  file.
  1769.  The  only  carriage  control characters that WRITE recognizes are '1', 
  1770.  '0', '+', and ' '.  Lines which start with  any  other  character  are
  1771.  ignored.   If  the  output  is  intended  for  a line-printer (see the 
  1772.  configuration variables), WRITE begins by printing a  line  consisting
  1773.  of the character 'Q' to de-select auto-page-eject.
  1774.   
  1775.       WRITE  reads  the  input file line by line, and converts to ASCII 
  1776.  codes as its internal character  set.   Linefeeds  (LF)  are  used  as
  1777.  end-of-line  characters,  formfeeds  (FF) are used as end-of-line fol-
  1778.  lowed by page eject, and carriage returns (CR) are used  to  represent 
  1779.  over-printing.   Thus  if  the  correct  translation  is  not  already 
  1780.  available in this program, it is relatively easy to add a new one. 
  1781.   
  1782.  Note: Some combinations may  not  be  meaningful  under  a  particular 
  1783.  operating system. 
  1784.  
  1785.       As  an  example,  any  of  the  Pascal-related writeups (and some
  1786.  others as well) at the University of Minnesota can be  reprocessed  by 
  1787.  WRITE: 
  1788.  
  1789.            WRITEUP,PASCAL=*/PT=AS,L=TEMP. 
  1790.            FETCH(WRITE) 
  1791.            WRITE(TEMP/TELEX)
  1792.  
  1793.       This  will  produce  a  version of the writeup for an interactive 
  1794.  terminal.
  1795.   
  1796.   
  1797.                                  - 2 -
  1798.   
  1799.  
  1800.  WRITE - A Writeup-Oriented Character Set Translator          03 Jan 79 
  1801.   
  1802.  APPENDIX - ASCII Character Set Information 
  1803.  ------------------------------------------ 
  1804.  
  1805.                                       Andy Mickel 78/08/17. 
  1806.                                       University Computer Center 
  1807.                                       University of Minnesota
  1808.   
  1809.       ASCII (American Standard Code for Information Interchange) is the
  1810.  American  variant of an officially-recognized, standard, international
  1811.  character set called the ISO  (International  Standards  Organization) 
  1812.  set.   It  specifies  an 8-bit code for 128 characters (7 bits + 1 bit 
  1813.  used for parity).  Within  the  ISO  code  there  may  exist  national 
  1814.  variants  for  certain symbols (such as the currency symbol: $ ).  The 
  1815.  128 characters consist of 95 which print as  single  graphics  and  33 
  1816.  which are used for device control.  The backspace control character is
  1817.  specifically used to allow overprinting of characters such as  accents 
  1818.  on some letters in foreign languages. 
  1819.  
  1820.       ASCII is the only character set to receive formal approval in the
  1821.  United States, having been adopted unanimously (including IBM)  within
  1822.  ANSI   (American  National  Standards  Institute)  during  the  period
  1823.  1963-65.  Of course IBM then made no  effort  to  change  from  EBCDIC
  1824.  (Extended  Binary  Coded  Decimal  Interchange Code), and so we in the
  1825.  computing field have 2 character sets to worry about. 
  1826.  
  1827.       Nevertheless ASCII is widely accepted as the industry standard by 
  1828.  an  overwhelming  number  of  computer  manufacturers, and most modern 
  1829.  equipment  (namely  interactive   terminals   and   personal   (micro)
  1830.  computers)  use  ASCII.   Today's programming languages are defined in
  1831.  terms of ASCII. 
  1832.  
  1833.      There are several official subsets of ASCII  as  well  (which  are
  1834.  presented  below).   The  63-  and  64-character subsets are for 6-bit 
  1835.  hardware representations onto which the other characters in full ASCII 
  1836.  may be folded.  Lower-case letters fold to upper case, curly braces to 
  1837.  square  brackets,  etc.   Even  the  keyboards  of  most   interactive
  1838.  terminals  exhibit the systematic ordering of ASCII for upper-case and 
  1839.  control characters. 
  1840.  
  1841.  The 63-character subset:
  1842.  
  1843.       0 1 2 3 4 5 6 7 8 9 
  1844.       A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
  1845.       + - * / = 
  1846.       ( ) [ ] < > ^
  1847.       ' " ! ? ; : , . 
  1848.       @ # $ & % _ 
  1849.       space
  1850.  
  1851.  The 64-character subset:
  1852.  
  1853.       the 63 set except [ and ] plus 
  1854.       { } \ 
  1855.  
  1856.  The 66-character subset:
  1857.   
  1858.                                  - 3 -
  1859.   
  1860.  
  1861.  WRITE - A Writeup-Oriented Character Set Translator          03 Jan 79 
  1862.   
  1863.  
  1864.       the 63 set plus 
  1865.       { } \ 
  1866.  
  1867.  The 89-character subset:
  1868.  
  1869.       the 63 set plus 
  1870.       a b c d e f g h i j k l m n o p q r s t u v w x y z 
  1871.  
  1872.  The 95-character subset:
  1873.  
  1874.       the 89 set plus 
  1875.       { } \ | ` ~
  1876.  
  1877.  The full 128-character set:
  1878.  
  1879.       the 95 set plus 
  1880.       the 33 control characters:
  1881.  
  1882.       ACK  (Acknowledge)                   FF   (Form Feed) 
  1883.       BEL  (Bell)                          FS   (File Separator)
  1884.       BS   (Backspace)                     GS   (Group Separator) 
  1885.       CAN  (Cancel)                        HT   (Horizontal Tab)
  1886.       CR   (Carriage Return)               LF   (Line Feed) 
  1887.       DC1  (Device Control 1)              NAK  (Negative Acknowledge)
  1888.       DC2  (Device Control 2)              NUL  (Null)
  1889.       DC3  (Device Control 3)              RS   (Record Separator)
  1890.       DC4  (Device Control 4)              SI   (Shift In)
  1891.       DEL  (Delete)                        SO   (Shift Out)
  1892.       DLE  (Data Link Escape)              SOH  (Start of Heading) 
  1893.       EM   (End of Medium)                 STX  (Start of Text) 
  1894.       ENQ  (Enquiry)                       SUB  (Substitute) 
  1895.       EOT  (End of Transmission)           SYN  (Synchronous Idle)
  1896.       ESC  (Escape)                        US   (Unit Separator)
  1897.       ETB  (End of Transmission Block)     VT   (Vertical Tab)
  1898.       ETX  (End of Text) 
  1899.  
  1900.              00   20   40   60  100  120  140  160
  1901.            ---------------------------------------- 
  1902.        0  | NUL  DLE        0    @    P    `    p 
  1903.        1  | SOH  DC1   !    1    A    Q    a    q
  1904.        2  | STX  DC2   "    2    B    R    b    r
  1905.        3  | ETX  DC3   #    3    C    S    c    s
  1906.        4  | EOT  DC4   $    4    D    T    d    t
  1907.        5  | ENQ  NAK   %    5    E    U    e    u 
  1908.        6  | ACK  SYN   &    6    F    V    f    v
  1909.        7  | BEL  ETB   '    7    G    W    g    w
  1910.       10  |  BS  CAN   (    8    H    X    h    x
  1911.       11  |  HT   EM   )    9    I    Y    i    y
  1912.       12  |  LF  SUB   *    :    J    Z    j    z
  1913.       13  |  VT  ESC   +    ;    K    [    k    {
  1914.       14  |  FF   FS   ,    <    L    \    l    |
  1915.       15  |  CR   GS   -    =    M    ]    m    }
  1916.       16  |  SO   RS   .    >    N    ^    n    ~ 
  1917.       17  |  SI   US   /    ?    O    _    o   DEL
  1918.   
  1919.  
  1920.                                  - 4 -
  1921.   
  1922.  
  1923.  WRITE - A Writeup-Oriented Character Set Translator          03 Jan 79 
  1924.   
  1925.       The 7-bit octal code for a character is the sum of the column 
  1926.       and row numbers.  For example, the code for the letter  G  is
  1927.       7 + 100 = 107 octal. 
  1928.   
  1929.  
  1930.  CDC KRONOS/NOS ASCII Representations (63-Character Set)
  1931.  ------------------------------------ 
  1932.  
  1933.  ---------------------                   -----------------------
  1934.  Internal Normal ASCII                   Internal Extended ASCII
  1935.  display  ------------                   display  --------------
  1936.  6/12-bit       7-bit                    6/12-bit        7-bit
  1937.  octal    char  octal                    octal    char   octal
  1938.  ---------------------                   -----------------------
  1939.    00                                      7600 
  1940.    01       A    101                       7601     a     141
  1941.    02       B    102                       7602     b     142
  1942.    03       C    103                       7603     c     143
  1943.    04       D    104                       7604     d     144
  1944.    05       E    105                       7605     e     145
  1945.    06       F    106                       7606     f     146
  1946.    07       G    107                       7607     g     147
  1947.    10       H    110                       7610     h     150
  1948.    11       I    111                       7611     i     151
  1949.    12       J    112                       7612     j     152
  1950.    13       K    113                       7613     k     153
  1951.    14       L    114                       7614     l     154
  1952.    15       M    115                       7615     m     155
  1953.    16       N    116                       7616     n     156
  1954.    17       O    117                       7617     o     157
  1955.    20       P    120                       7620     p     160
  1956.    21       Q    121                       7621     q     161
  1957.    22       R    122                       7622     r     162
  1958.    23       S    123                       7623     s     163
  1959.    24       T    124                       7624     t     164
  1960.    25       U    125                       7625     u     165
  1961.    26       V    126                       7626     v     166
  1962.    27       W    127                       7627     w     167
  1963.    30       X    130                       7630     x     170
  1964.    31       Y    131                       7631     y     171
  1965.    32       Z    132                       7632     z     172
  1966.    33       0    060                       7633     {     173
  1967.    34       1    061                       7634     |     174
  1968.    35       2    062                       7635     }     175
  1969.    36       3    063                       7636     ~     176
  1970.    37       4    064                       7637    DEL    177 
  1971.    40       5    065                       7640    NUL    000 
  1972.    41       6    066                       7641    SOH    001 
  1973.    42       7    067                       7642    STX    002 
  1974.    43       8    070                       7643    ETX    003 
  1975.    44       9    071                       7644    EOT    004 
  1976.    45       +    053                       7645    ENQ    005 
  1977.    46       -    055                       7646    ACK    006 
  1978.    47       *    052                       7647    BEL    007 
  1979.    50       /    057                       7650     BS    010 
  1980.   
  1981.                                  - 5 -
  1982.   
  1983.  
  1984.  WRITE - A Writeup-Oriented Character Set Translator          03 Jan 79 
  1985.   
  1986.    51       (    050                       7651     HT    011 
  1987.    52       )    051                       7652     LF    012 
  1988.    53       $    044                       7653     VT    013 
  1989.    54       =    075                       7654     FF    014 
  1990.    55     SPACE  040                       7655     CR    015 
  1991.    56       ,    054                       7656     SO    016 
  1992.    57       .    056                       7657     SI    017 
  1993.    60       #    043                       7660    DLE    020 
  1994.    61       [    133                       7661    DC1    021 
  1995.    62       ]    135                       7662    DC2    022 
  1996.    63       :    072                       7663    DC3    023 
  1997.    64       "    042                       7664    DC4    024 
  1998.    65       _    137                       7665    NAK    025 
  1999.    66       !    041                       7666    SYN    026 
  2000.    67       &    046                       7667    ETB    027 
  2001.    70       '    047                       7670    CAN    030 
  2002.    71       ?    077                       7671     EM    031 
  2003.    72       <    074                       7672    SUB    032 
  2004.    73       >    076                       7673    ESC    033 
  2005.    74       @    100                       7674     FS    034
  2006.    75       \    134                       7675     GS    035 
  2007.    76       ^    136                       7676     RS    036
  2008.    77       ;    073                       7677     US    037 
  2009.  ---------------------                     7400 
  2010.                                            7401     @     100
  2011.                                            7402     ^     136
  2012.                                            7403 
  2013.                                            7404     %     045
  2014.                                            7405 
  2015.                                            7406 
  2016.                                            7407     `     140
  2017.                                          -----------------------
  2018.  
  2019.  References
  2020.  ========== 
  2021.  
  2022.  "A View of the History of the ISO Character Code"
  2023.   R.  W.  Bemer in HONEYWELL COMPUTER JOURNAL, Vol.  6, No.  4,
  2024.   1972, pp 274-289. 
  2025.  
  2026.  "Hints on Distributing Portable Software" 
  2027.   William Waite in SOFTWARE PRACTICE AND EXPERIENCE, Vol.  5, 
  2028.   1975, pp 295-308. 
  2029.  
  2030.  NOS 1.2 REFERENCE MANUAL VOLUME 1, CDC, Pub.  No.  60435400,
  2031.   Appendix A.
  2032.   
  2033.   
  2034.   
  2035.   
  2036.   
  2037.   
  2038.                                  - 6 -
  2039. /